﻿using MP_Game.Protos.V1;
using MP_Network;
using MP_Server.Ctrls;

namespace MP_Server
{
    internal class GatewayServer
    {
        static async Task Main(string[] args)
        {
            // 创建grpc服务器
            var app = new GrpcServer(args)
                .AddSingleton<ForwardSvc>()
                .MapGrpcService<ForwardSvc>()
                .StartServer(NetConst.IPHost, NetConst.CenterServerGrpcPort);

            // 创建网关服务器，传入VerifyServer客户端引用
            NetServer server = new NetServer("网关服务器", null);
            server.StartServer(NetConst.IPHost, NetConst.CenterServerPort);
            // 注册转发控制器
            ForwardCtrl forwardCtrl = new ForwardCtrl(app.Services.GetRequiredService<ForwardSvc>());
            server.RegistCommand(CmdId.CmdLoginReq, forwardCtrl);
            server.RegistCommand(CmdId.CmdLoginRsp, forwardCtrl);

            await app.WaitForShutdownAsync();
        }
    }
}
